package cn.tedu.sort;

import org.junit.Test;

public class BubbleSort extends BasicSort {

    @Override
    protected void sort(Comparable[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (less(arr[j + 1], arr[j])) {
                    exch(arr, j, j + 1);
                }
            }
        }
    }

    @Test
    public void test() {
        generateNumbers();
        sort(numbers);
        show();
    }
}
